package com.meitianhui.convenitenbuy.module.mine.presenter;

import com.meitianhui.convenitenbuy.App;
import com.meitianhui.convenitenbuy.http.ResponseObserver;
import com.meitianhui.convenitenbuy.main.model.bean.UserToken;
import com.meitianhui.convenitenbuy.module.mine.contract.AccountSecurityContract;
import com.meitianhui.convenitenbuy.module.mine.http.MineApiDataSource;
import com.meitianhui.convenitenbuy.module.mine.ui.activity.AccountSecurityActivity;

/**
 * Created by amy on 2017/11/10.
 */

public class AccountSecurityPresenter implements AccountSecurityContract.Presenter {

    private AccountSecurityContract.View mView;
    private AccountSecurityActivity mContext;

    public AccountSecurityPresenter(AccountSecurityActivity activity,
                                    AccountSecurityActivity context) {
        this.mContext = context;
        this.mView = activity;
    }

    @Override
    public void attachView(Object view) {
    }

    @Override
    public void detachView() {
    }

    /**
     * 保存用户小额免密信息
     */
    @Override
    public void saveSmallAccountSetting(UserToken userToken) {
        MineApiDataSource.getInstance()
                .payWithoutPwAndSmsNotify(userToken.getUser_token(),
                        userToken.getSmall_direct_flag(), userToken.getSms_notify_flag())
                .subscribe(new ResponseObserver<Object>(App.getInstance()) {
                    @Override
                    public void onSuccess(Object o) {
                        // 保存成功鉣
                        mView.settingSuccess();
                    }
                });
    }

}
